<template>
	<view>
		<uni-card>
			<template v-slot:cover>
				<image :src="website.imgFile" :mode="scaleToFill" style="height: 380upx; width: 100%;"></image>
			</template>
			<uni-title type="h1" :title="website.name" align="center" style="color: #398ADE;"></uni-title>

			<view style="display:flex; flex-direction:row; justify-content:center;">
				<uni-tag :text="website.type" type="warning" style="margin-right: 20rpx;" />
				<uni-tag text="网站资源" type="primary" />
			</view>
			<view style="margin-top: 35rpx;">
				<uni-row>
					<uni-col :span="4">
						<text style="font-size: 30rpx; font-weight: 300; color: #303133;margin-left: 20upx;">链接:</text>
					</uni-col>
					<uni-col :span="18">
						<text
							style="font-size: 25rpx; font-weight: bold; color: #007AFF;white-space:normal;word-break:break-all;word-warp:break-word;">{{website.url}}</text>
					</uni-col>
					<uni-col :span="2">
						<uni-icons type="link" size="25" @click="copy()"></uni-icons>

					</uni-col>
				</uni-row>
			</view>

			<view style="margin-top: 10rpx;">
				<uni-row style="margin-top: 10rpx;">
					<uni-col :span="4">
						<text style="font-size: 30rpx; font-weight: 300; color: #303133;margin-left: 20upx;">简介:</text>
					</uni-col>
					<uni-col :span="20">
						<text style="font-size: 25rpx; font-weight: 200; color: #555555;">{{website.introduce}}</text>
					</uni-col>
				</uni-row>
			</view>

			<view style="margin-top: 35rpx;">
				<uni-row style="margin-top: 10rpx;">
					<uni-col :span="4">
						<text style="font-size: 30rpx; font-weight: 300; color: #303133;margin-left: 20upx;">时间:</text>
					</uni-col>
					<uni-col :span="20">
						<text style="font-size: 25rpx; font-weight: 200; color: #555555;">{{website.updateTime}}</text>
					</uni-col>
				</uni-row>
			</view>

			<!-- <view style="display:flex; flex-direction:row; justify-content:center; margin: 50rpx;">
				<button type="primary" size="mini" @click="copy()">复制网站链接</button>
			</view> -->

		</uni-card>
		<ad unit-id="adunit-39b53761b10c9de2" ad-type="video" ad-theme="white"></ad>
	</view>
	
</template>

<script>
	import Utils from '../../Utils.js'
	export default {
		data() {
			return {
				website: {}
			}
		},
		methods: {
			onLoad: function(e) {
				Utils.interstitial.load('adunit-5b3adb633e4a887a')
				this.getWebiste(JSON.parse(e.id))
				uni.setNavigationBarTitle({
					title: this.website.name
				})
				
				setTimeout(() => {
					//设置延迟执行
					Utils.interstitial.show()
				}, 0);
			},
			copy() {
				uni.setClipboardData({
					data: this.website.url,
				})
			},

			getWebiste(id){
				uni.request({
					url: this.$api + '/website/getById/' + id,
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					method: 'GET',
					//请求成功后返回
					success: (res) => {
						// 请求成功之后将数据给Info
						if (res.data.code === '200') {
							this.website = res.data.data;
							//时间截取
							this.website.updateTime = this.website.updateTime.slice(0, this.website.updateTime
								.indexOf(" "));
							this.website.imgFile = this.$api + '/img/' + this.website.imgFile;
							
						}
				
					},
				
					fail: (res) => {
						console.log(res)
						uni.showToast({
							title: "请求错误:" + res.errMsg,
							icon: 'none',
							duration: 850
						});
					}
				
				});
			},

			//分享朋友
			onShareAppMessage(res) {
				return {
					title: this.website.name,
					path: '/pages/websitepage/websitepage?id=' + JSON.stringify(this.website.id),
					imageUrl: this.website.imgFile,
				}
			},
			//分享到朋友圈
			onShareTimeline(res) {
				return {
					title: "Howe科技-" + this.website.name,
					path: '/pages/websitepage/websitepage?id=' + JSON.stringify(this.website.id),
					imageUrl: this.website.imgFile,
				}
			},

		}
	}
</script>

<style>

</style>
